home *** CD-ROM | disk | FTP | other *** search
- /*
- File: Array.h
-
- Contains: xxx put contents here xxx
-
- Written by: Essam Zaky
-
- Copyright: © 1994 by Apple Computer, Inc., all rights reserved.
-
- Change History (most recent first):
-
- <4> 1/5/94 EZ clean up
- <3> 1/5/94 EZ remove CLongArray to LinkedFrames.cp
- <2> 1/4/94 EZ clean up
- <1> 1/4/94 EZ first checked in
-
- */
-
- #ifndef _Array_
- #define _Array_
-
- #ifndef _ToolBoxDump_
- #include "ToolBoxDump.h"
- #endif
-
- #ifndef _TextensionCommon_
- #include "TextensionCommon.h"
- #endif
- //***************************************************************************************************
-
- #ifdef txtnDebug
- extern short gCountArrays;
- #endif
-
- class CArray : public HandleObject {
- public:
- CArray();
-
- void IArray(short arrayElementSize, short moreElementsCount = 0);
-
- virtual void Free();
-
- void* LockArray(Boolean moveHi = false);
- void UnlockArray();
-
- void* GetElementPtr(long elementIndex) const;
- void* GetLastElementPtr() const;
-
- void SetElementsVal(long elementIndex, const void* newElementsPtr, long countElements = 1);
- void GetElementsVal(long elementIndex, void* elementsPtr, long countElements = 1);
-
- void* InsertElements(long countToInsert, const void* newElementsVal, long insertIndex=-1);
- //-1 means at the end. newElementsVal may be nil
-
- virtual long RemoveElements(long removeIndex, long countToRemove);
- //returns the new elements count
-
- OSErr ReplaceElements(long oldCount, long newCount, long replaceIndex, const void* newElements);
- //newElements may be nil
-
- inline long CountElements() const {return fElementsCount;}
-
- OSErr SetElementsCount(long newCount, Boolean compact =false);
- void Compact();
-
- OSErr Reserve(long extraCount);
-
- inline short GetElementSize() {return fElementSize;}
-
- protected:
- long fElementsCount;
- short fElementSize;
-
- private:
- #ifdef __STDC__
- Handle fHandle;
- #else
- long fOffset;
- #endif
-
- short fLockLevel;
- short fMoreElementsCount;
- long fActualElementsCount;
-
- OSErr SetArraySize(long newElementsCount);
- };
- //***************************************************************************************************
-
- class CLongTagArray : public CArray {
- //Array of elements starting with a long
- public:
- CLongTagArray();
-
- long Search(long val, long* foundVal) const;
-
- long SearchBigger(long val) const;
-
- private:
- };
- //***************************************************************************************************
-
- #endif
-